home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / FuzAxon / GausFuz.c < prev   
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.6 KB  |  51 lines

  1. // Dynamic link library implementation of NeuroSolutions Axon component
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /***********************************/
  6. /* Forward activation of component */
  7.  
  8. __declspec(dllexport) void performFuzzyAxon(
  9.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *param,     // Pointer to the layer of parameters for the MFs
  14.     int        paramIndex,    // Index into the param array
  15.     int        PEIndex,    // Index into the processing elements of the Axon
  16.                         // (the data array)
  17.     NSFloat *returnVal    // Value to return after applying the MF
  18.     )
  19. {
  20.     int baseIndex = paramIndex * 2;
  21.     NSFloat c = *(param + baseIndex);
  22.     NSFloat sigma = *(param + baseIndex + 1);
  23.     if (sigma == 0.0f)
  24.         *returnVal = 0.0f;
  25.     else {
  26.         NSFloat exp_fraction = (*(data + PEIndex) - c) / sigma;
  27.         NSFloat exp_final = (NSFloat) (((double)exp_fraction*(double)exp_fraction) / (double)-2.0);
  28.         *returnVal = (NSFloat)exp(exp_final);
  29.     }
  30. }
  31.  
  32. /******************************************/
  33. /* Management of instance data (OPTIONAL) */
  34.  
  35. __declspec(dllexport) DLLData *allocFuzzyAxon(
  36.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  37.     int     rows,        // Number of rows of PEs in the layer
  38.     int     cols,        // Number of columns of PEs in the layer
  39.     int        *paramCount    // Number of parameters per MF
  40.     )
  41. {
  42.     DLLData *instance = allocDLLInstance(oldInstance);
  43.     *paramCount = 2;
  44.     return instance;
  45. }
  46.  
  47. __declspec(dllexport) void freeFuzzyAxon(DLLData *instance)
  48. {
  49.     freeDLLInstance(instance);
  50. }
  51.